package com.ruoyi.project.jiaqin.supplyclassval.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.supplyclassval.domain.SupplyClassAttrVal;
import com.ruoyi.project.jiaqin.supplyclassval.service.ISupplyClassAttrValService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 分类属性值Controller
 * 
 * @author admin
 * @date 2021-01-28
 */
@Controller
@RequestMapping("/jiaqin/supplyclassval")
public class SupplyClassAttrValController extends BaseController
{
    private String prefix = "jiaqin/supplyclassval";

    @Autowired
    private ISupplyClassAttrValService supplyClassAttrValService;

    @RequiresPermissions("jiaqin:supplyclassval:view")
    @GetMapping()
    public String supplyclassval()
    {
        return prefix + "/supplyclassval";
    }

    /**
     * 查询分类属性值列表
     */
    @RequiresPermissions("jiaqin:supplyclassval:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SupplyClassAttrVal supplyClassAttrVal)
    {
        startPage();
        List<SupplyClassAttrVal> list = supplyClassAttrValService.selectSupplyClassAttrValList(supplyClassAttrVal);
        return getDataTable(list);
    }

    /**
     * 导出分类属性值列表
     */
    @RequiresPermissions("jiaqin:supplyclassval:export")
    @Log(title = "分类属性值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SupplyClassAttrVal supplyClassAttrVal)
    {
        List<SupplyClassAttrVal> list = supplyClassAttrValService.selectSupplyClassAttrValList(supplyClassAttrVal);
        ExcelUtil<SupplyClassAttrVal> util = new ExcelUtil<SupplyClassAttrVal>(SupplyClassAttrVal.class);
        return util.exportExcel(list, "supplyclassval");
    }

    /**
     * 新增分类属性值
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存分类属性值
     */
    @RequiresPermissions("jiaqin:supplyclassval:add")
    @Log(title = "分类属性值", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SupplyClassAttrVal supplyClassAttrVal)
    {
        return toAjax(supplyClassAttrValService.insertSupplyClassAttrVal(supplyClassAttrVal));
    }

    /**
     * 修改分类属性值
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        SupplyClassAttrVal supplyClassAttrVal = supplyClassAttrValService.selectSupplyClassAttrValById(id);
        mmap.put("supplyClassAttrVal", supplyClassAttrVal);
        return prefix + "/edit";
    }

    /**
     * 修改保存分类属性值
     */
    @RequiresPermissions("jiaqin:supplyclassval:edit")
    @Log(title = "分类属性值", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SupplyClassAttrVal supplyClassAttrVal)
    {
        return toAjax(supplyClassAttrValService.updateSupplyClassAttrVal(supplyClassAttrVal));
    }

    /**
     * 删除分类属性值
     */
    @RequiresPermissions("jiaqin:supplyclassval:remove")
    @Log(title = "分类属性值", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(supplyClassAttrValService.deleteSupplyClassAttrValByIds(ids));
    }
}
